package springinpractice.common.util;

import org.apache.commons.lang.StringUtils;
import org.springframework.validation.BindingResult;

/*
 * Author       :       Willie Wheeler and John Wheeler
 * Book         :       'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 */

public final class ValidationUtil {
	
	public static void verifyBinding(BindingResult result) {
		String[] suppressedFields = result.getSuppressedFields();
		if (suppressedFields.length > 0) {
			throw new RuntimeException("You've attempted to bind fields that haven't been allowed in initBinder(): " 
					+ StringUtils.join(suppressedFields, ", "));
		}
	}	
}
